package com.example.spring_source_code.bean.life.cycle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class BeanLifeCycle {
    public static final  Logger logger = LoggerFactory.getLogger(BeanLifeCycle.class);

    @Autowired
    public void autowired(@Value("${JAVA_HOME}") String javaHome) {
        logger.info("依赖注入");
    }

    public BeanLifeCycle() {
        logger.info("构造");
    }

    @PostConstruct
    public void init() {
        logger.info("初始化");
    }

    @PreDestroy
    public void destroy() {
        logger.info("销毁");
    }



}
